<?php
//打开目录
$dir = opendir("./");

//列出目录中的文件
while (($file_name = readdir($dir)) !== false)
    {
        if($file_name!='.'&&$file_name!='..')
        {
            $array_file_name = explode(".",$file_name);
            if($array_file_name[count($array_file_name)-1]=='html')
            {
                echo "filename: " . $file_name . "<br />";
                $orignal_content = file_get_contents($file_name);
                $replaced_content = str_replace(array('{','}'),array('<?php echo $',';?>'),$orignal_content);
                echo $replaced_content;
                $array_file_name[count($array_file_name)-1] = 'php';
                print_r($array_file_name);
                $new_file_name = implode('.',$array_file_name);
                echo $new_file_name;
                file_put_contents($new_file_name,$replaced_content);

            }
        }
    }
  closedir($dir);

//file_get_contents()
?>